package com.stx.jeepay.manager.controller;

import com.stx.jeepay.core.cache.Cache;
import com.stx.jeepay.core.entity.SysLogEntity;
import com.stx.jeepay.core.model.ApiRes;
import com.stx.jeepay.core.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Api("测试")
@RestController
@RequestMapping("/api/test")
public class TestController {
    @Autowired
    private SysLogService sysLogService;

    @Autowired
    private Cache cache;


    @ApiOperation("测试Redis")
    @GetMapping("/testRedis")
    public ApiRes testRedis(){
        cache.setString("1","testRedis");
        return ApiRes.ok();
    }

    @ApiOperation("测试")
    @GetMapping("/test")
    public void test(){
        SysLogEntity entity = new SysLogEntity();
        entity.setSysLogId(123);
        entity.setUserId(1L);
        entity.setUserName("test");
        entity.setUserIp("123");
        entity.setSysType("11");
        entity.setMethodName("name");
        entity.setMethodRemark("mark");
        entity.setReqUrl("url");
        entity.setOptReqParam("params");
        entity.setOptResInfo("info");
        entity.setCreatedAt(new Date());
        sysLogService.save(entity);
    }
}
